package errors

import (
	"fmt"
)

/*
自定义错误类
*/

type CustomError struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

func (e *CustomError) Error() string {
	return fmt.Sprintf("Code: %d, Msg: %s", e.Code, e.Msg)
}

var (
	ErrUserAlreadyExists    = &CustomError{Code: 5001, Msg: "User already exists!"}
	ErrUsrNotFound          = &CustomError{Code: 5002, Msg: "User not found!"}
	ErrJsonAnalyze          = &CustomError{Code: 5003, Msg: "Unable to parse json!"}
	ErrPWD                  = &CustomError{Code: 5004, Msg: "Error password"}
	ErrEmail                = &CustomError{Code: 5005, Msg: "Error email"}
	ErrTableErr             = &CustomError{Code: 5006, Msg: "Chart query error"}
	ErrJsonFormat           = &CustomError{Code: 5007, Msg: "invalid JSON format"}
	ErrCommentErr           = &CustomError{Code: 5008, Msg: "Comment acquisition error"}
	ErrCommentAlreadyExists = &CustomError{Code: 5009, Msg: "Comment already exists!"}
	ErrPWDFormat            = &CustomError{Code: 4001, Msg: "Password format error!"}
	ErrEmailFormat          = &CustomError{Code: 4002, Msg: "Email format error!"}
	ErrName                 = &CustomError{Code: 4002, Msg: "Name format error!"}
	ErrRole                 = &CustomError{Code: 4003, Msg: "Illegal authority!"}
)
